home *** CD-ROM | disk | FTP | other *** search
- integer valid1,valid2,valid3;
- real timeArray[];
-
- ** This block divides the top input by the bottom.
- ** Copyright © 1989-1992 by Imagine That, Inc.
- ** All Rights Reserved.
- ** Extend Generic Library, Divide block; Alfy Riddle
- ** modified 1/1/92 JSL modified for V2.0
-
- procedure calc()
- {
- ** check for divide by zero only. Don't check for NaN
- if( Con2In == 0.0 AND stopIt )
- {
- userError("Divide by zero in Divide, block number "+(MyBlockNumber()));
- abort;
- }
-
- ConOut = Con1In / Con2In;
-
- ** sysGlobal2 is the file reference number for the DEBUG TRACE
- if( sysGlobal2 != 0.0 ) ** 0 is error, check for open file for TRACE
- {
- fileWrite(sysGlobal2,"Divide block number "+(MyBlockNumber()),"",True);
- fileWrite(sysGlobal2,"Top Input = "+con1In,"",True);
- fileWrite(sysGlobal2,"Bottom Input = "+con2In,"",True);
- fileWrite(sysGlobal2,"Output = "+conOut,"",True);
- fileWrite(sysGlobal2," ","",True);
- }
- }
-
-
- ** This message occurs for each step in the simulation.
- on Simulate
- {
- calc();
- }
-
-
- on endSim
- {
- ** sysGlobal1 is the file reference number for the TEXT REPORT
- if( sysGlobal1 != 0.0 ) ** 0 is error, check for open file for REPORT
- {
- fileWrite(sysGlobal1,"Divide block number "+(MyBlockNumber()),"",True);
- if( stopIt )
- fileWrite(sysGlobal1,"Stops simulation on divide by zero","",True);
- else
- fileWrite(sysGlobal1,"Outputs a noValue on divide by zero","",True);
- if( comments != "" )
- fileWrite(sysGlobal1,"Comments = "+comments,"",True);
- fileWrite(sysGlobal1," ","",True);
- }
- }
-
-
- ** If the dialog data is inconsistent for simulation, abort.
- on checkData
- {
- sysGlobal1 = 0.0; ** prevent false reports
- sysGlobal2 = 0.0; ** prevent false debugs
-
- valid1 = Con1In; ** 1 if connected, 0 if not
- valid2 = Con2In; ** 1 if connected, 0 if not
-
- if( valid1 + valid2 < 2 )
- {
- userError("Both Connectors must be used in Divide, block number "+(MyBlockNumber()));
- abort;
- }
- }
-
-
- ** Initialize any simulation variables.
- on initSim
- {
- if( getPassedArray(sysGlobal0, timeArray) )
- getSimulateMsgs(FALSE);
- }
-
-
- on createBlock
- {
- putNaN = TRUE;
- }